home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 7 / BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso / Files / Tele / W-Z / Y Modem(Watson) < prev    next >
Text File  |  1987-11-03  |  49KB  |  1,650 lines

  1. L.L.Bean  1 800 257 12347
  2.  
  3.  
  4.                   - 1 -
  5.  
  6.  
  7.  
  8.              XMODEM/YMODEM PROTOCOL REFERENCE
  9.          A compendium of documents describing the
  10.  
  11.                 XMODEM and YMODEM
  12.  
  13.              File Transfer Protocols
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.              Edited    by Chuck Forsberg
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.          Please    distribute as widely as    possible.
  41.  
  42.                Questions to Chuck Forsberg
  43.  
  44.  
  45.  
  46.  
  47.  
  48.                Omen    Technology Inc
  49.             17505-V    Sauvie Island Road
  50.               Portland Oregon 97231
  51.                Voice: 503-621-3406
  52.         Modem (Telegodzilla): 503-621-3746 Speed 1200,300
  53.               Compuserve: 70715,131
  54.             UUCP: ...!tektronix!reed!omen!caf
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.                   - 2 -
  71.  
  72.  
  73.  
  74. 1.  ROSETTA STONE
  75.  
  76. Here are some definitions which    reflect    the current vernacular in the
  77. computer media.     The attempt here is identify the file transfer    protocol
  78. rather than specific programs.
  79.  
  80. XMODEM    refers to the original 1979 file transfer etiquette introduced by
  81.     Ward Christensen's 1979    MODEM2 program.     It's also called the
  82.     MODEM or MODEM2    protocol.  Some    who are    unaware    of MODEM7's
  83.     unusual    batch file mode    call it    MODEM7.     Other aliases include
  84.     "CP/M User's Group" and "TERM II FTP 3".  This    protocol is
  85.     supported by every serious communications program because of its
  86.     universality, simplicity, and reasonable performance.
  87.  
  88. XMODEM/CRC replaces XMODEM's 1 byte checksum with a two    byte Cyclical
  89.     Redundancy Check    (CRC-16), giving modern    error detection
  90.     protection.
  91.  
  92. YMODEM    refers to the XMODEM/CRC protocol with the throughput and/or batch
  93.     transmission enhancements described below.
  94.  
  95.  
  96. 2.  YET    ANOTHER    PROTOCOL?
  97.  
  98. Since its development half a decade ago, the Ward Christensen modem
  99. protocol has enabled a wide variety of computer    systems    to interchange
  100. data.  There is    hardly a communications    program    that doesn't at    least
  101. claim to support this protocol.
  102.  
  103. Recent advances    in computing, modems and networking have revealed a number
  104. of weaknesses in the original protocol:
  105.  
  106.    + The short block length caused throughput to suffer    when used with
  107.      timesharing systems, packet switched networks, satellite circuits,
  108.      and buffered (error correcting) modems.
  109.  
  110.    + The 8 bit arithmetic checksum and other aspects allowed line
  111.      impairments to interfere with dependable, accurate    transfers.
  112.  
  113.    + Only one file could be sent per command.  The file    name had to be
  114.      given twice, first    to the sending program and then    again to the
  115.      receiving program.
  116.  
  117.    + The transmitted file could    accumulate as many as 127 extraneous
  118.      bytes.
  119.  
  120.    + The modification date of the file was lost.
  121.  
  122. A number of other protocols have been developed    over the years,    but none
  123. have displaced XMODEM to date:
  124.  
  125.  
  126.  
  127.  
  128. Chapter    2
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. X/YMODEM Protocol Reference     10-10-85                 3
  137.  
  138.  
  139.  
  140.    + Lack of public domain documentation and example programs have kept
  141.      proprietary protocols such    as MNP,    Blast, and others tightly bound    to
  142.      the fortunes of their suppliers.
  143.  
  144.    + Complexity    discourages the    widespread application of BISYNC, SDLC,
  145.      HDLC, X.25, and X.PC protocols.
  146.  
  147.    + Performance compromises and moderate complexity have limited the
  148.      popularity    of the Kermit protocol,    which was developed to allow file
  149.      transfers in environments hostile to XMODEM.
  150.  
  151. The YMODEM Protocol extensions were developed as a means of addressing the
  152. weaknesses described above while maintaining XMODEM's simplicity as much
  153. as possible.
  154.  
  155. YMODEM is supported by the public domain programs YAM (CP/M),
  156. YAM(CP/M-86), YAM(CCPM-86), IMP    (CP/M),    KMD (CP/M), MODEM76.ASM    (CP/M),
  157. rb/sb (Unix, VMS, Berkeley Unix, Venix,    Xenix, Coherent, IDRIS,    Regulus)
  158. as well    as Professional-YAM.1 These programs have been in use since 1981.
  159.  
  160. The 1k packet length capability    described below    may be used in conjunction
  161. with the Batch Protocol, or with single    file transfers identical to the
  162. XMODEM/CRC protocol except for the minimal changes to support 1k packets.
  163.  
  164. Another    extension is simply called the g option.  It provides maximum
  165. throughput when    used with end to end error correcting media, such as X.PC
  166. and error correcting modems, including the emerging 9600 bps units by
  167. Electronic Vaults and others.
  168.  
  169. To complete this tome, Ward Christensen's original protocol document and
  170. John Byrns's CRC-16 document are included for reference.
  171.  
  172. References to the MODEM    or MODEM7 protocol have    been changed to    XMODEM to
  173. accommodate the    vernacular.  In    Australia, it is properly called the
  174. Christensen Protocol.
  175.  
  176. Watch for an article describing    the YMODEM protocol in a more coherent
  177. fashion    later this year.  The article will include some    interesting
  178. history    on the development of microcomputer file transfers.
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187. __________
  188.  
  189.  1. Available for IBM PC,XT,AT,    Unix and Xenix
  190.  
  191.  
  192.  
  193.  
  194. Chapter    2
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. X/YMODEM Protocol Reference     10-10-85                 4
  203.  
  204.  
  205.  
  206. 2.1  Some Messages from    the Pioneer
  207.  
  208. #: 130940 S0/Communications 25-Apr-85  18:38:47
  209. Sb: my protocol
  210. Fm: Ward Christensen 76703,302 (EDITED)
  211. To: all
  212.  
  213. Be aware the article2 DID quote    me correctly in    terms of the phrases like
  214. "not robust", etc.
  215.  
  216. It was a quick hack I threw together, very unplanned (like everything I
  217. do), to    satisfy    a personal need    to communicate with "some other" people.
  218.  
  219. ONLY the fact that it was done in 8/77,    and that I put it in the public
  220. domain immediately, made it become the standard    that it    is.
  221.  
  222. I think    its time for me    to
  223.  
  224. (1) document it; (people call me and say "my product is    going to include
  225. it - what can I    'reference'", or "I'm writing a    paper on it, what do I put
  226. in the bibliography") and
  227.  
  228. (2) propose an "incremental extension" to it, which might take "exactly"
  229. the form of Chuck Forsberg's YAM protocol.  He wrote YAM in C for CP/M and
  230. put it in the public domain, and wrote a batch protocol    for Unix3 called
  231. rb and sb (receive batch, send batch), which was basically XMODEM with
  232.    (a) a record    0 containing filename date time    and size
  233.    (b) a 1K block size option
  234.    (c) CRC-16.
  235.  
  236. He did some clever programming to detect false ACK or EOT, but basically
  237. left them the same.
  238.  
  239. People who suggest I make SIGNIFICANT changes to the protocol, such as
  240. "full duplex", "multiple outstanding blocks", "multiple    destinations", etc
  241. etc don't understand that the incredible simplicity of the protocol is one
  242. of the reasons it survived to this day in as many machines and programs    as
  243. it may be found    in!
  244.  
  245. Consider the PC-NET group back in '77 or so - documenting to beat the band
  246. - THEY had a protocol, but it was "extremely complex", because it tried    to
  247. be "all    things to all people" -    i.e. send binary files on a 7-bit system,
  248. etc.  I    was not    that "benevolent". I (emphasize    > I < )    had an 8-bit UART,
  249.  
  250.  
  251. __________
  252.  
  253.  2. Infoworld April 29 p. 16
  254.  
  255.  3. VAX/VMS versions of    these programs are also    available.
  256.  
  257.  
  258.  
  259.  
  260. Chapter    2
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. X/YMODEM Protocol Reference     10-10-85                 5
  269.  
  270.  
  271.  
  272. so "my protocol    was an 8-bit protocol",    and I would just say "sorry" to
  273. people who were    held back by 7-bit limitations.     ...
  274.  
  275. Block size: Chuck Forsberg created an extension    of my protocol,    called
  276. YAM, which is also supported via his public domain programs for    UNIX
  277. called rb and sb - receive batch and send batch.  They cleverly    send a
  278. "block 0" which    contains the filename, date, time, and size.
  279. Unfortunately, its UNIX    style, and is a    bit weird4 - octal numbers, etc.
  280. BUT, it    is a nice way to overcome the kludgy "echo the chars of    the name"
  281. introduced with    MODEM7.     Further, chuck    uses CRC-16 and    optional 1K
  282. blocks.     Thus the record 0, 1K,    and CRC, make it a "pretty slick new
  283. protocol" which    is not significantly different from my own.
  284.  
  285. Also, there is a catchy    name - YMODEM.    That means to some that    it is the
  286. "next thing after XMODEM", and to others that it is the    Y(am)MODEM
  287. protocol.  I don't want    to emphasize that too much - out of fear that
  288. other mfgrs might think    it is a    "competitive" protocol,    rather than an
  289. "unaffiliated" protocol.  Chuck    is currently selling a much-enhanced
  290. version    of his CP/M-80 C program YAM, calling it Professional Yam, and its
  291. for the    PC - I'm using it right    now.  VERY slick!  32K capture buffer,
  292. script,    scrolling, previously captured text search, plus built-in commands
  293. for just about everything - directory (sorted every which way),    XMODEM,
  294. YMODEM,    KERMIT,    and ASCII file upload/download,    etc.  You can program it
  295. to "behave" with most any system - for example when trying a number for
  296. CIS it detects the "busy" string back from the modem and substitutes a
  297. diff phone # into the dialing string and branches back to try it.
  298.  
  299.  
  300.  
  301. 3.  XMODEM PROTOCOL ENHANCEMENTS
  302.  
  303. This chapter discusses the protocol extensions to Ward Christensen's 1982
  304. XMODEM protocol    description document.
  305.  
  306. The original document recommends the user be asked whether to continue
  307. trying or abort    after 10 retries.  Most    programs no longer ask the
  308. operator whether he wishes to keep retrying.  Virtually    all correctable
  309. errors are corrected within the    first few retransmissions.  If the line    is
  310. so bad that ten    attempts are insufficient, there is a significant danger
  311. of undetected errors.  If the connection is that bad, it's better to
  312. redial for a better connection,    or mail    a floppy disk.
  313.  
  314.  
  315.  
  316.  
  317.  
  318. __________
  319.  
  320.  4. The    file length, time, and file mode are optional.    The pathname and
  321.     file length    may be sent alone if desired.
  322.  
  323.  
  324.  
  325.  
  326. Chapter    3                      XMODEM Protocol Enhancements
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. X/YMODEM Protocol Reference     10-10-85                 6
  335.  
  336.  
  337.  
  338. 3.1  Graceful Abort
  339.  
  340. YAM and    Professional-YAM recognize a sequence of two consecutive CAN (Hex
  341. 18) characters without modem errors (overrun, framing, etc.) as    a transfer
  342. abort command.1    The check for two consecutive CAN characters virtually
  343. eliminates the possibility of a    line hit aborting the transfer.     YAM sends
  344. five CAN characters when it aborts an XMODEM or    YMODEM protocol    file
  345. transfer, followed by five backspaces to delete    the CAN    characters from
  346. the remote's keyboard input buffer (in case the    remote had already aborted
  347. the transfer).
  348.  
  349.  
  350. 3.2  CRC-16 Option
  351.  
  352. The XMODEM protocol uses an optional two character CRC-16 instead of the
  353. one character arithmetic checksum used by the original protocol    and by
  354. most commercial    implementations.  CRC-16 guarantees detection of all
  355. single and double bit errors,  all errors with an odd number of    error
  356. bits, all burst    errors of length 16 or less, 99.9969% of all 17-bit error
  357. bursts,    and 99.9984 per    cent of    all possible longer error bursts.  By
  358. contrast, a double bit error, or a burst error of 9 bits or more can sneak
  359. past the XMODEM    protocol arithmetic checksum.
  360.  
  361. The XMODEM/CRC protocol    is similar to the XMODEM protocol, except that the
  362. receiver specifies CRC-16 by sending C (Hex 43)    instead    of NAK when
  363. requesting the FIRST packet.  A    two byte CRC is    sent in    place of the one
  364. byte arithmetic    checksum.
  365.  
  366. YAM's c    option to the r    command    enables    CRC-16 in single file reception,
  367. corresponding to the original implementation in    the MODEM7 series
  368. programs.  This    remains    the default because many commercial communications
  369. programs and bulletin board systems still do not support CRC-16,
  370. especially those written in Basic or Pascal.
  371.  
  372. XMODEM protocol    with CRC is accurate provided both sender and receiver
  373. both report a successful transmission.    The protocol is    robust in the
  374. presence of characters lost by buffer overloading on timesharing systems.
  375.  
  376. The single character ACK/NAK responses generated by the    receiving program
  377. adapt well to split speed modems, where    the reverse channel is limited to
  378. ten per    cent or    less of    the main channel's speed.
  379.  
  380. XMODEM and YMODEM are half duplex protocols which do not attempt to
  381. transmit information and control signals in both directions at the same
  382.  
  383.  
  384. __________
  385.  
  386.  1. This is recognized when YAM    is waiting for the beginning of    a packet
  387.     or for an acknowledge to one that has been sent.
  388.  
  389.  
  390.  
  391.  
  392. Chapter    3                      XMODEM Protocol Enhancements
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400. X/YMODEM Protocol Reference     10-10-85                 7
  401.  
  402.  
  403.  
  404. time.  This avoids buffer overrun problems that    have been reported by
  405. users attempting to exploit full duplex    asynchronous file transfer
  406. protocols such as Blast.
  407.  
  408. Professional-YAM adds several proprietary logic    enhancements to    XMODEM's
  409. error detection    and recovery.  These compatible    enhancements eliminate
  410. most of    the bad    file transfers other programs make when    using the XMODEM
  411. protocol under less than ideal conditions.
  412.  
  413.  
  414. 3.3  1024 Byte Packet Option
  415.  
  416. The choice to use 1024 byte packets is expressed to the    sending    program    on
  417. its command line or selection menu.
  418.  
  419. Programs using the Hoff    protocol use a two character sequence emitted by
  420. the receiver (CK) to automatically trigger the use of 1024 byte    packets    as
  421. an alternative to specifying this option on this command line.    Although
  422. this two character sequence works well on single process micros    in direct
  423. communication, timesharing systems and packet switched networks    can
  424. separate the successive    characters by several seconds, rendering this
  425. method unreliable.
  426.  
  427. An STX (02) replaces the SOH (01) at the beginning of the transmitted
  428. block to notify    the receiver of    the longer packet length.  The transmitted
  429. packet contains    1024 bytes of data.  The receiver should be able to accept
  430. any mixture of 128 and 1024 byte packets.  The packet number is
  431. incremented by one for each packet regardless of the packet length.
  432.  
  433. The sender must    not change between 128 and 1024    byte packet lengths if it
  434. has not    received a valid ACK for the current packet.  Failure to observe
  435. this restriction allows    certain    transmission errors to pass undetected.
  436.  
  437. If 1024    byte packets are being used, it    is possible for    a file to "grow"
  438. up to the next multiple    of 1024    bytes.    This does not waste disk space if
  439. the allocation granularity is 1k or greater.  When 1024    byte packets are
  440. used with YMODEM batch transmission, the file length transmitted in the
  441. file name packet allows    the receiver to    discard    the padding, preserving
  442. the exact file length and contents.
  443.  
  444. CRC-16 should be used with the k option    to preserve data integrity over
  445. phone lines.2 1024 byte    packets    may be used with batch file transmission
  446. or with    single file transmission.
  447.  
  448.  
  449.  
  450.  
  451. __________
  452.  
  453.  2. Some programs enforce this recommendation.
  454.  
  455.  
  456.  
  457.  
  458. Chapter    3                      XMODEM Protocol Enhancements
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466. X/YMODEM Protocol Reference     10-10-85                 8
  467.  
  468.  
  469.  
  470.       Figure 1.  1024 byte Packets
  471.  
  472.       SENDER                  RECEIVER
  473.                           "s -k    foo.bar"
  474.       "foo.bar open    x.x minutes"
  475.                           C
  476.       STX 01 FE Data[1024] CRC CRC
  477.                           ACK
  478.       STX 02 FD Data[1024] CRC CRC
  479.                           ACK
  480.       STX 03 FC Data[1000] CPMEOF[24] CRC CRC
  481.                           ACK
  482.       EOT
  483.                           ACK
  484.  
  485.       Figure 2.  Mixed 1024    and 128    byte Packets
  486.  
  487.       SENDER                  RECEIVER
  488.                           "s -k    foo.bar"
  489.       "foo.bar open    x.x minutes"
  490.                           C
  491.       STX 01 FE Data[1024] CRC CRC
  492.                           ACK
  493.       STX 02 FD Data[1024] CRC CRC
  494.                           ACK
  495.       SOH 03 FC Data[128] CRC CRC
  496.                           ACK
  497.       SOH 04 FB Data[100] CPMEOF[28] CRC CRC
  498.                           ACK
  499.       EOT
  500.                           ACK
  501.  
  502. 4.  YMODEM Batch File Transmission
  503.  
  504. The YMODEM Batch protocol is an    extension to the XMODEM/CRC protocol that
  505. allows 0 or more files to be transmitted with a    single command.     (Zero
  506. files may be sent if none of the requested files is accessible.) The
  507. design approach    of the YMODEM Batch protocol is    to use the normal routines
  508. for sending and    receiving XMODEM packets in a layered fashion similar to
  509. packet switching methods.
  510.  
  511. Why was    it necessary to    design a new batch protocol when one already
  512. existed    in MODEM7?1 The    batch file mode    used by    MODEM7 is unsuitable
  513.  
  514.  
  515. __________
  516.  
  517.  1. The    MODEM7 batch protocol transmitted CP/M FCB bytes f1...f8 and
  518.     t1...t3 one    character at a time.  The receiver echoed these    bytes as
  519.     received, one at a time.
  520.  
  521.  
  522.  
  523.  
  524. Chapter    4                      XMODEM Protocol Enhancements
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532. X/YMODEM Protocol Reference     10-10-85                 9
  533.  
  534.  
  535.  
  536. because    it does    not permit full    pathnames, file    length,    file date, or
  537. other attribute    information to be transmitted.    Such a restrictive design,
  538. hastily    implemented with only CP/M in mind, would not have permitted
  539. extensions to current areas of personal    computing such as Unix,    DOS, and
  540. object oriented    systems.  In addition, the MODEM7 batch    file mode is
  541. somewhat susceptible to    transmission impairments.
  542.  
  543. As in the case of single a file    transfer, the receiver initiates batch
  544. file transmission by sending a "C" character (for CRC-16).
  545.  
  546. The sender opens the first file    and sends packet number    0 with the
  547. following information.2
  548.  
  549. Only the pathname (file    name) part is required for batch transfers.
  550.  
  551. To maintain upwards compatibility, all unused bytes in packet 0    must be
  552. set to null.
  553.  
  554. Pathname The pathname (conventionally, the file    name) is sent as a null
  555.      terminated    ASCII string.  This is the filename format used    by the
  556.      handle oriented MSDOS(TM) functions and C library fopen functions.
  557.      An    assembly language example follows:
  558.                   DB      'foo.bar',0
  559.      No    spaces are included in the pathname.  Normally only the    file name
  560.      stem (no directory    prefix)    is transmitted unless the sender has
  561.      selected YAM's f option to    send the full pathname.     The source drive
  562.      (A:, B:, etc.) is never sent.
  563.  
  564.      Filename Considerations:
  565.  
  566.     + File names should be translated to lower case    unless the sending
  567.       system supports upper/lower case file    names.    This is    a
  568.       convenience for users    of systems (such as Unix) which    store
  569.       filenames in upper and lower case.
  570.  
  571.     + The receiver should accommodate file names in    lower and upper
  572.       case.
  573.  
  574.     + The rb(1) program on Unix systems normally translates    the
  575.       filename to lower case unless    one or more letters in the
  576.       filename are already in lower    case.
  577.  
  578.     + When transmitting files between different operating systems,
  579.       file names must be acceptable    to both    the sender and receiving
  580.       operating systems.
  581.  
  582.  
  583. __________
  584.  
  585.  2. Only the data part of the packet is    described here.
  586.  
  587.  
  588.  
  589.  
  590. Chapter    4                      XMODEM Protocol Enhancements
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598. X/YMODEM Protocol Reference     10-10-85                10
  599.  
  600.  
  601.  
  602.      If    directories are    included, they are delimited by    /; i.e.,
  603.      "subdir/foo" is acceptable, "subdir\foo" is not.
  604.  
  605. Length The file    length and each    of the succeeding fields are optional.3
  606.      The length    field is stored    in the packet as a decimal string counting
  607.      the number    of data    bytes in the file.  The    file length does not
  608.      include any CPMEOF    (^Z) characters    used to    pad the    last packet.
  609.  
  610.      If    the file being transmitted is growing during transmission, the
  611.      length field should be set    to at least the    final expected file
  612.      length, or    not sent.
  613.  
  614.      The receiver stores the specified number of characters, discarding
  615.      any padding added by the sender to    fill up    the last packet.
  616.  
  617. Modification Date A single space separates the modification date from the
  618.      file length.
  619.  
  620.      The mod date is optional, and the filename    and length may be sent
  621.      without requiring the mod date to be sent.
  622.  
  623.      The mod date is sent as an    octal number giving the    time the contents
  624.      of    the file were last changed measured in seconds from Jan    1 1970
  625.      Universal Coordinated Time    (GMT).    A date of 0 implies the
  626.      modification date is unknown and should be    left as    the date the file
  627.      is    received.
  628.  
  629.      This standard format was chosen to    eliminate ambiguities arising from
  630.      transfers between different time zones.
  631.  
  632.      Two Microsoft blunders complicate the use of modification dates in
  633.      file transfers with MSDOS(TM) systems.  The first is the lack of
  634.      timezone standardization in MS-DOS.  A file's creation time can not
  635.      be    known unless the timezone of the system    that wrote the file4 is
  636.      known.  Unix solved this problem (for planet Earth, anyway) by
  637.      stamping files with Universal Time    (GMT).    Microsoft would    have to
  638.      include the timezone of origin in the directory entries, but does
  639.      not.  Professional-YAM gets around    this problem by    using the z
  640.      parameter which is    set to the number of minutes local time    lags GMT.
  641.      For files known to    originate from a different timezone, the -zT
  642.      option may    be used    to specify T as    the timezone for an individual
  643.      file transfer.
  644.  
  645.  
  646.  
  647. __________
  648.  
  649.  3. Fields may not be skipped.
  650.  
  651.  4. Not    necessarily that of the    transmitting system!
  652.  
  653.  
  654.  
  655.  
  656. Chapter    4                      XMODEM Protocol Enhancements
  657.  
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664. X/YMODEM Protocol Reference     10-10-85                11
  665.  
  666.  
  667.  
  668.      The second    problem    is the lack of a separate file creation    date in
  669.      DOS.  Since some backup schemes used with DOS rely    on the file
  670.      creation date to select files to be copied    to the archive,    back-
  671.      dating the    file modification date could interfere with the    safety of
  672.      the transferred files.  For this reason, Professional-YAM does not
  673.      modify the    date of    received files with the    header information unless
  674.      the d parameter is    non zero.
  675.  
  676.  
  677. Mode A single space separates the file mode from the modification date.
  678.      The file mode is stored as    an octal string.  Unless the file
  679.      originated    from a Unix system, the    file mode is set to 0.    rb(1)
  680.      checks the    file mode for the 0x8000 bit which indicates a Unix type
  681.      regular file.  Files with the 0x8000 bit set are assumed to have been
  682.      sent from another Unix (or    similar) system    which uses the same file
  683.      conventions.  Such    files are not translated in any    way.
  684.  
  685.  
  686. Serial Number A    single space separates the serial number from the file
  687.      mode.  The    serial number of the transmitting program is stored as an
  688.      octal string.  Programs which do not have a serial    number should omit
  689.      this field, or set    it to 0.  The receiver's use of    this field is
  690.      optional.
  691.  
  692. The rest of the    packet is set to nulls.     This is essential to preserve
  693. upward compatibility.5 After the filename packet has been received, it is
  694. ACK'ed if the write open is successful.     The receiver then initiates
  695. transfer of the    file contents according    to the standard    XMODEM/CRC
  696. protocol.  If the file cannot be opened    for writing, the receiver cancels
  697. the transfer with CAN characters as described above.
  698.  
  699. After the file contents    have been transmitted, the receiver again asks for
  700. the next pathname.  Transmission of a null pathname terminates batch file
  701. transmission.  Note that transmission of no files is not necessarily an
  702. error.    This is    possible if none of the    files requested    of the sender
  703. could be opened    for reading.
  704.  
  705. In batch transmission, the receiver automatically requests CRC-16.
  706.  
  707. The Unix programs sb(1)    and rb(1) included in the source code file
  708. RBSB.SHQ (rbsb.sh) should answer other questions about YMODEM batch
  709. protocol.
  710.  
  711.  
  712.  
  713. __________
  714.  
  715.  5. If,    perchance, this    information extends beyond 128 bytes (possible
  716.     with Unix 4.2 BSD extended file names), the    packet should be sent as a
  717.     1k packet as described above.
  718.  
  719.  
  720.  
  721.  
  722. Chapter    4                      XMODEM Protocol Enhancements
  723.  
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730. X/YMODEM Protocol Reference     10-10-85                12
  731.  
  732.  
  733.  
  734.       Figure 3.  Batch Transmission    Session
  735.  
  736.       SENDER                  RECEIVER
  737.                           "sb foo.*<CR>"
  738.       "sending in batch mode etc."
  739.                           C (command:rb)
  740.       SOH 00 FF foo.c NUL[123] CRC CRC
  741.                           ACK
  742.                           C
  743.       SOH 01 FE Data[128] CRC CRC
  744.                           ACK
  745.       SOH 02 FD Data[1024] CRC CRC
  746.                           ACK
  747.       SOH 03 FC Data[128] CRC CRC
  748.                           ACK
  749.       SOH 04 FB Data[100] CPMEOF[28] CRC CRC
  750.                           ACK
  751.       EOT
  752.                           NAK
  753.       EOT
  754.                           ACK
  755.                           C
  756.       SOH 00 FF NUL[128] CRC CRC
  757.                           ACK
  758.  
  759.        Figure 4.  Filename packet transmitted by sb
  760.  
  761.        -rw-r--r--  6347    Jun 17 1984 20:34 bbcsched.txt
  762.  
  763.        00 0100FF62 62637363 6865642E 74787400    |...bbcsched.txt.|
  764.        10 36333437 20333331 34373432 35313320    |6347 3314742513 |
  765.        20 31303036 34340000 00000000 00000000    |100644..........|
  766.        30 00000000 00000000 00000000 00000000
  767.        80 000000CA 56
  768.  
  769.  
  770.  
  771.  
  772.  
  773.  
  774.  
  775.  
  776.  
  777.  
  778.  
  779.  
  780.  
  781.  
  782.  
  783.  
  784.  
  785.  
  786.  
  787.  
  788. Chapter    4                      XMODEM Protocol Enhancements
  789.  
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796. X/YMODEM Protocol Reference     10-10-85                13
  797.  
  798.  
  799.  
  800.        Figure 5.  Header Information used by YMODEM Implementations
  801.  
  802.  
  803. _____________________________________________________________________
  804. | Program   | Batch | Length | Date | Mode | S/N | 1k-Blk | g-Option |
  805. |___________|_______|________|______|______|_____|________|__________|
  806. |Unix rb/sb | yes   | yes    | yes  | yes  | no     | yes      | sb only  |
  807. |___________|_______|________|______|______|_____|________|__________|
  808. |VMS rb/sb  | yes   | yes    | no   | no   | no     | yes      | no         |
  809. |___________|_______|________|______|______|_____|________|__________|
  810. |Pro-YAM    | yes   | yes    | yes  | no   | yes | yes      | yes         |
  811. |___________|_______|________|______|______|_____|________|__________|
  812. |CP/M YAM   | yes   | no     | no   | no   | no     | yes      | no         |
  813. |___________|_______|________|______|______|_____|________|__________|
  814. |KMD/IMP    | yes   | no     | no   | no   | no     | yes      | no         |
  815. |___________|_______|________|______|______|_____|________|__________|
  816. |MEX        | no    | no     | no   | no   | no     | yes      | no         |
  817. |___________|_______|________|______|______|_____|________|__________|
  818.  
  819. 4.1  IMP/KMD Record Count
  820.  
  821. Due to programming constraints,    these programs do not send the file length
  822. as described above.  Instead, they send    (and look for) the CP/M    record
  823. count stored in    the last two bytes of the header packet.  The least
  824. significant bits are stored in the penultimate byte.
  825.  
  826. KMD and    IMP use    the record count to allow the receiving    program    to display
  827. the file size and estimated transmission time; the file    length is
  828. determined by the actual number    of records sent.
  829.  
  830.  
  831. 5.  g Option File Transmission
  832.  
  833. Developing technology is providing phone line data transmission    at ever
  834. higher speeds using very specialized techniques.  These    high speed modems,
  835. as well    as session protocols such as X.PC, provide high    speed, error free
  836. communications at the expense of considerably increased    delay time.
  837.  
  838. This delay time    is moderate compared to    human interactions, but    it
  839. cripples the throughput    of most    error correcting protocols.
  840.  
  841. The g option to    YMODEM has proven effective under these    circumstances.
  842. The g option is    driven by the receiver,    which initiates    the batch transfer
  843. by transmitting    a G instead of C.  When    the sender recognizes the G, it
  844. bypasses the usual wait    for an ACK to each transmitted packet, sending
  845. succeeding packets at full speed, subject to XOFF/XON or other flow
  846. control    exerted    by the medium.
  847.  
  848. The sender expects an initial G to initiate the transmission of a
  849. particular file, and also expects an ACK on the    EOT sent at the    end of
  850. each file.  This synchronization allows    the receiver time to open and
  851.  
  852.  
  853.  
  854. Chapter    5                      XMODEM Protocol Enhancements
  855.  
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862. X/YMODEM Protocol Reference     10-10-85                14
  863.  
  864.  
  865.  
  866. close files as necessary.
  867.  
  868.  
  869.     Figure 6.  g Option Transmission Session
  870.  
  871.     SENDER                    RECEIVER
  872.                         "sb foo.*<CR>"
  873.     "sending in batch mode etc..."
  874.                         G (command:rb -g)
  875.     SOH 00 FF foo.c    NUL[123] CRC CRC
  876.                         G
  877.     SOH 01 FE Data[128] CRC    CRC
  878.     SOH 02 FD Data[1024] CRC CRC
  879.     SOH 03 FC Data[128] CRC    CRC
  880.     SOH 04 FB Data[100] CPMEOF[28] CRC CRC
  881.     EOT
  882.                         ACK
  883.                         G
  884.     SOH 00 FF NUL[128] CRC CRC
  885.  
  886.  
  887. 6.  XMODEM PROTOCOL OVERVIEW
  888.  
  889. 8/9/82 by Ward Christensen.
  890.  
  891. I will maintain    a master copy of this.    Please pass on changes or
  892. suggestions via    CBBS/Chicago at    (312) 545-8086,    CBBS/CPMUG (312) 849-1132
  893. or by voice at (312) 849-6279.
  894.  
  895. 6.1  Definitions
  896.  
  897.   <soh>       01H
  898.   <eot>       04H
  899.   <ack>       06H
  900.   <nak>       15H
  901.   <can>       18H
  902.   <C>       43H
  903.  
  904.  
  905. 6.2  Transmission Medium Level Protocol
  906.  
  907. Asynchronous, 8    data bits, no parity, one stop bit.
  908.  
  909. The protocol imposes no    restrictions on    the contents of    the data being
  910. transmitted.  No control characters are    looked for in the 128-byte data
  911. messages.  Absolutely any kind of data may be sent - binary, ASCII, etc.
  912. The protocol has not formally been adopted to a    7-bit environment for the
  913. transmission of    ASCII-only (or unpacked-hex) data , although it    could be
  914. simply by having both ends agree to AND    the protocol-dependent data with
  915. 7F hex before validating it.  I    specifically am    referring to the checksum,
  916. and the    block numbers and their    ones- complement.
  917.  
  918.  
  919.  
  920. Chapter    6                      Xmodem Protocol Overview
  921.  
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928. X/YMODEM Protocol Reference     10-10-85                15
  929.  
  930.  
  931.  
  932. Those wishing to maintain compatibility    of the CP/M file structure, i.e.
  933. to allow modeming ASCII files to or from CP/M systems should follow this
  934. data format:
  935.  
  936.    + ASCII tabs    used (09H); tabs set every 8.
  937.  
  938.    + Lines terminated by CR/LF (0DH 0AH)
  939.  
  940.    + End-of-file indicated by ^Z, 1AH.    (one or    more)
  941.  
  942.    + Data is variable length, i.e. should be considered    a continuous
  943.      stream of data bytes, broken into 128-byte    chunks purely for the
  944.      purpose of    transmission.
  945.  
  946.    + A CP/M "peculiarity": If the data ends exactly on a 128-byte
  947.      boundary, i.e. CR in 127, and LF in 128, a    subsequent sector
  948.      containing    the ^Z EOF character(s)    is optional, but is preferred.
  949.      Some utilities or user programs still do not handle EOF without ^Zs.
  950.  
  951.    + The last block sent is no different from others, i.e.  there is no
  952.      "short block".
  953.           Figure 7.     XMODEM    Message    Block Level Protocol
  954.  
  955. Each block of the transfer looks like:
  956.       <SOH><blk    #><255-blk #><--128 data bytes--><cksum>
  957. in which:
  958. <SOH>          =    01 hex
  959. <blk #>          =    binary number, starts at 01 increments by 1, and
  960.         wraps 0FFH to 00H (not to 01)
  961. <255-blk #>   =    blk # after going thru 8080 "CMA" instr, i.e.
  962.         each bit complemented in the 8-bit block number.
  963.         Formally, this is the "ones complement".
  964. <cksum>          =    the sum    of the data bytes only.     Toss any carry.
  965.  
  966. 6.3  File Level    Protocol
  967.  
  968. 6.3.1  Common_to_Both_Sender_and_Receiver
  969. All errors are retried 10 times.  For versions running with an operator
  970. (i.e. NOT with XMODEM),    a message is typed after 10 errors asking the
  971. operator whether to "retry or quit".
  972.  
  973. Some versions of the protocol use <can>, ASCII ^X, to cancel transmission.
  974. This was never adopted as a standard, as having    a single "abort" character
  975. makes the transmission susceptible to false termination    due to an <ack>
  976. <nak> or <soh> being corrupted into a <can> and    canceling transmission.
  977.  
  978. The protocol may be considered "receiver driven", that is, the sender need
  979. not automatically re-transmit, although    it does    in the current
  980. implementations.
  981.  
  982.  
  983.  
  984.  
  985.  
  986. Chapter    6                      Xmodem Protocol Overview
  987.  
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994. X/YMODEM Protocol Reference     10-10-85                16
  995.  
  996.  
  997.  
  998. 6.3.2  Receive_Program_Considerations
  999. The receiver has a 10-second timeout.  It sends    a <nak>    every time it
  1000. times out.  The    receiver's first timeout, which    sends a    <nak>, signals the
  1001. transmitter to start.  Optionally, the receiver    could send a <nak>
  1002. immediately, in    case the sender    was ready.  This would save the    initial    10
  1003. second timeout.     However, the receiver MUST continue to    timeout    every 10
  1004. seconds    in case    the sender wasn't ready.
  1005.  
  1006. Once into a receiving a    block, the receiver goes into a    one-second timeout
  1007. for each character and the checksum.  If the receiver wishes to    <nak> a
  1008. block for any reason (invalid header, timeout receiving    data), it must
  1009. wait for the line to clear.  See "programming tips" for    ideas
  1010.  
  1011. Synchronizing:    If a valid block number    is received, it    will be: 1) the
  1012. expected one, in which case everything is fine;    or 2) a    repeat of the
  1013. previously received block.  This should    be considered OK, and only
  1014. indicates that the receivers <ack> got glitched, and the sender    re-
  1015. transmitted; 3)    any other block    number indicates a fatal loss of
  1016. synchronization, such as the rare case of the sender getting a line-glitch
  1017. that looked like an <ack>.  Abort the transmission, sending a <can>
  1018.  
  1019.  
  1020. 6.3.3  Sending_program_considerations
  1021. While waiting for transmission to begin, the sender has    only a single very
  1022. long timeout, say one minute.  In the current protocol,    the sender has a
  1023. 10 second timeout before retrying.  I suggest NOT doing    this, and letting
  1024. the protocol be    completely receiver-driven.  This will be compatible with
  1025. existing programs.
  1026.  
  1027. When the sender    has no more data, it sends an <eot>, and awaits    an <ack>,
  1028. resending the <eot> if it doesn't get one.  Again, the protocol    could be
  1029. receiver-driven, with the sender only having the high-level 1-minute
  1030. timeout    to abort.
  1031.  
  1032.  
  1033. Here is    a sample of the    data flow, sending a 3-block message.  It includes
  1034. the two    most common line hits -    a garbaged block, and an <ack> reply
  1035. getting    garbaged.  <xx>    represents the checksum    byte.
  1036.  
  1037.  
  1038.  
  1039.  
  1040.  
  1041.  
  1042.  
  1043.  
  1044.  
  1045.  
  1046.  
  1047.  
  1048.  
  1049.  
  1050.  
  1051.  
  1052. Chapter    6                      Xmodem Protocol Overview
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060. X/YMODEM Protocol Reference     10-10-85                17
  1061.  
  1062.  
  1063.  
  1064.           Figure 8.     Data flow including Error Recovery
  1065.  
  1066. SENDER                    RECEIVER
  1067.                   times out    after 10 seconds,
  1068.                   <---        <nak>
  1069. <soh> 01 FE -data- <xx>          --->
  1070.                   <---        <ack>
  1071. <soh> 02 FD -data- xx          --->     (data gets line hit)
  1072.                   <---        <nak>
  1073. <soh> 02 FD -data- xx          --->
  1074.                   <---        <ack>
  1075. <soh> 03 FC -data- xx          --->
  1076. (ack gets garbaged)          <---        <ack>
  1077. <soh> 03 FC -data- xx          --->        <ack>
  1078. <eot>                  --->
  1079.                   <---     <anything except ack>
  1080. <eot>                  --->
  1081.                   <---        <ack>
  1082. (finished)
  1083.  
  1084. 6.4  Programming Tips
  1085.  
  1086.    + The character-receive subroutine should be    called with a parameter
  1087.      specifying    the number of seconds to wait.    The receiver should first
  1088.      call it with a time of 10,    then <nak> and try again, 10 times.
  1089.  
  1090.      After receiving the <soh>,    the receiver should call the character
  1091.      receive subroutine    with a 1-second    timeout, for the remainder of the
  1092.      message and the <cksum>.  Since they are sent as a    continuous stream,
  1093.      timing out    of this    implies    a serious like glitch that caused, say,
  1094.      127 characters to be seen instead of 128.
  1095.  
  1096.    + When the receiver wishes to <nak>,    it should call a "PURGE"
  1097.      subroutine, to wait for the line to clear.     Recall    the sender tosses
  1098.      any characters in its UART    buffer immediately upon    completing sending
  1099.      a block, to ensure    no glitches were mis- interpreted.
  1100.  
  1101.      The most common technique is for "PURGE" to call the character
  1102.      receive subroutine, specifying a 1-second timeout,1 and looping back
  1103.      to    PURGE until a timeout occurs.  The <nak> is then sent, ensuring
  1104.      the other end will    see it.
  1105.  
  1106.    + You may wish to add code recommended by John Mahr to your character
  1107.      receive routine - to set an error flag if the UART    shows framing
  1108.      error, or overrun.     This will help    catch a    few more glitches - the
  1109.  
  1110.  
  1111. __________
  1112.  
  1113.  1. These times    should be adjusted for use with    timesharing systems.
  1114.  
  1115.  
  1116.  
  1117.  
  1118. Chapter    6                      Xmodem Protocol Overview
  1119.  
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126. X/YMODEM Protocol Reference     10-10-85                18
  1127.  
  1128.  
  1129.  
  1130.      most common of which is a hit in the high bits of the byte    in two
  1131.      consecutive bytes.     The <cksum> comes out OK since    counting in 1-byte
  1132.      produces the same result of adding    80H + 80H as with adding 00H +
  1133.      00H.
  1134.  
  1135.  
  1136.  
  1137. 7.  XMODEM/CRC Overview
  1138.  
  1139. 1/13/85    by John    Byrns -- CRC option.
  1140.  
  1141. Please pass on any reports of errors in    this document or suggestions for
  1142. improvement to me via Ward's/CBBS at (312) 849-1132, or    by voice at (312)
  1143. 885-1105.
  1144.  
  1145. The CRC    used in    the Modem Protocol is an alternate form    of block check
  1146. which provides more robust error detection than    the original checksum.
  1147. Andrew S. Tanenbaum says in his    book, Computer Networks, that the CRC-
  1148. CCITT used by the Modem    Protocol will detect all single    and double bit
  1149. errors,    all errors with    an odd number of bits, all burst errors    of length
  1150. 16 or less, 99.997% of 17-bit error bursts, and    99.998%    of 18-bit and
  1151. longer bursts.
  1152.  
  1153. The changes to the Modem Protocol to replace the checksum with the CRC are
  1154. straight forward. If that were all that    we did we would    not be able to
  1155. communicate between a program using the    old checksum protocol and one
  1156. using the new CRC protocol. An initial handshake was added to solve this
  1157. problem. The handshake allows a    receiving program with CRC capability to
  1158. determine whether the sending program supports the CRC option, and to
  1159. switch it to CRC mode if it does. This handshake is designed so    that it
  1160. will work properly with    programs which implement only the original
  1161. protocol. A description    of this    handshake is presented in section 10.
  1162.  
  1163.         Figure 9.  Message Block Level Protocol, CRC mode
  1164.  
  1165. Each block of the transfer in CRC mode looks like:
  1166.      <SOH><blk #><255-blk #><--128 data    bytes--><CRC hi><CRC lo>
  1167. in which:
  1168. <SOH>         = 01 hex
  1169. <blk #>         = binary number, starts at    01 increments by 1, and
  1170.            wraps 0FFH to 00H (not to 01)
  1171. <255-blk #>  = ones complement of blk #.
  1172. <CRC hi>     = byte containing the 8 hi    order coefficients of the CRC.
  1173. <CRC lo>     = byte containing the 8 lo    order coefficients of the CRC.
  1174.  
  1175. 7.1  CRC Calculation
  1176.  
  1177. 7.1.1  Formal_Definition
  1178. To calculate the 16 bit    CRC the    message    bits are considered to be the
  1179. coefficients of    a polynomial. This message polynomial is first multiplied
  1180. by X^16    and then divided by the    generator polynomial (X^16 + X^12 + X^5    +
  1181.  
  1182.  
  1183.  
  1184. Chapter    7                      Xmodem Protocol Overview
  1185.  
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192. X/YMODEM Protocol Reference     10-10-85                19
  1193.  
  1194.  
  1195.  
  1196. 1) using modulo    two arithmetic.    The remainder left after the division is
  1197. the desired CRC. Since a message block in the Modem Protocol is    128 bytes
  1198. or 1024    bits, the message polynomial will be of    order X^1023. The hi order
  1199. bit of the first byte of the message block is the coefficient of X^1023    in
  1200. the message polynomial.     The lo    order bit of the last byte of the message
  1201. block is the coefficient of X^0    in the message polynomial.
  1202.  
  1203.        Figure 10.  Example of CRC Calculation written in C
  1204.  
  1205. /*
  1206.  * This    function calculates the    CRC used by the    XMODEM/CRC Protocol
  1207.  * The first argument is a pointer to the message block.
  1208.  * The second argument is the number of    bytes in the message block.
  1209.  * The function    returns    an integer which contains the CRC.
  1210.  * The low order 16 bits are the coefficients of the CRC.
  1211.  */
  1212. int calcrc(ptr,    count)
  1213. char *ptr;
  1214. int count;
  1215. {
  1216.     int    crc, i;
  1217.  
  1218.     crc    = 0;
  1219.     while (--count >= 0) {
  1220.        crc = crc ^ (int)*ptr++ << 8;
  1221.        for (i = 0; i < 8; ++i)
  1222.            if (crc & 0x8000)
  1223.            crc = crc <<    1 ^ 0x1021;
  1224.            else
  1225.            crc = crc <<    1;
  1226.        }
  1227.     return (crc    & 0xFFFF);
  1228. }
  1229.  
  1230. 7.2  CRC File Level Protocol Changes
  1231.  
  1232. 7.2.1  Common_to_Both_Sender_and_Receiver
  1233. The only change    to the File Level Protocol for the CRC option is the
  1234. initial    handshake which    is used    to determine if    both the sending and the
  1235. receiving programs support the CRC mode. All Modem Programs should support
  1236. the checksum mode for compatibility with older versions.  A receiving
  1237. program    that wishes to receive in CRC mode implements the mode setting
  1238. handshake by sending a <C> in place of the initial <nak>.  If the sending
  1239. program    supports CRC mode it will recognize the    <C> and    will set itself
  1240. into CRC mode, and respond by sending the first    block as if a <nak> had
  1241. been received. If the sending program does not support CRC mode    it will
  1242. not respond to the <C> at all. After the receiver has sent the <C> it will
  1243. wait up    to 3 seconds for the <soh> that    starts the first block.    If it
  1244. receives a <soh> within    3 seconds it will assume the sender supports CRC
  1245. mode and will proceed with the file exchange in    CRC mode. If no    <soh> is
  1246. received within    3 seconds the receiver will switch to checksum mode, send
  1247.  
  1248.  
  1249.  
  1250. Chapter    7                      Xmodem Protocol Overview
  1251.  
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258. X/YMODEM Protocol Reference     10-10-85                20
  1259.  
  1260.  
  1261.  
  1262. a <nak>, and proceed in    checksum mode. If the receiver wishes to use
  1263. checksum mode it should    send an    initial    <nak> and the sending program
  1264. should respond to the <nak> as defined in the original Modem Protocol.
  1265. After the mode has been    set by the initial <C> or <nak>    the protocol
  1266. follows    the original Modem Protocol and    is identical whether the checksum
  1267. or CRC is being    used.
  1268.  
  1269.  
  1270. 7.2.2  Receive_Program_Considerations
  1271. There are at least 4 things that can go    wrong with the mode setting
  1272. handshake.
  1273.  
  1274.   1.  the initial <C> can be garbled or    lost.
  1275.  
  1276.   2.  the initial <soh>    can be garbled.
  1277.  
  1278.   3.  the initial <C> can be changed to    a <nak>.
  1279.  
  1280.   4.  the initial <nak>    from a receiver    which wants to receive in checksum
  1281.       can be changed to    a <C>.
  1282.  
  1283. The first problem can be solved    if the receiver    sends a    second <C> after
  1284. it times out the first time. This process can be repeated several times.
  1285. It must    not be repeated    too many times before sending a    <nak> and
  1286. switching to checksum mode or a    sending    program    without    CRC support may
  1287. time out and abort. Repeating the <C> will also    fix the    second problem if
  1288. the sending program cooperates by responding as    if a <nak> were    received
  1289. instead    of ignoring the    extra <C>.
  1290.  
  1291. It is possible to fix problems 3 and 4 but probably not    worth the trouble
  1292. since they will    occur very infrequently. They could be fixed by    switching
  1293. modes in either    the sending or the receiving program after a large number
  1294. of successive <nak>s. This solution would risk other problems however.
  1295.  
  1296.  
  1297. 7.2.3  Sending_Program_Considerations
  1298. The sending program should start in the    checksum mode. This will insure
  1299. compatibility with checksum only receiving programs. Anytime a <C> is
  1300. received before    the first <nak>    or <ack> the sending program should set
  1301. itself into CRC    mode and respond as if a <nak> were received. The sender
  1302. should respond to additional <C>s as if    they were <nak>s until the first
  1303. <ack> is received. This    will assist the    receiving program in determining
  1304. the correct mode when the <soh>    is lost    or garbled. After the first <ack>
  1305. is received the    sending    program    should ignore <C>s.
  1306.  
  1307.  
  1308.  
  1309.  
  1310.  
  1311.  
  1312.  
  1313.  
  1314.  
  1315.  
  1316. Chapter    7                      Xmodem Protocol Overview
  1317.  
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324. X/YMODEM Protocol Reference     10-10-85                21
  1325.  
  1326.  
  1327.  
  1328. 7.3  Data Flow Examples    with CRC Option
  1329.  
  1330. Here is    a data flow example for    the case where the receiver requests
  1331. transmission in    the CRC    mode but the sender does not support the CRC
  1332. option.    This example also includes various transmission    errors.     <xx>
  1333. represents the checksum    byte.
  1334.  
  1335.       Figure 11.  Data Flow: Receiver has CRC Option, Sender Doesn't
  1336.  
  1337. SENDER                          RECEIVER
  1338.             <---            <C>
  1339.                 times out after    3 seconds,
  1340.             <---            <C>
  1341.                 times out after    3 seconds,
  1342.             <---            <C>
  1343.                 times out after    3 seconds,
  1344.             <---            <C>
  1345.                 times out after    3 seconds,
  1346.             <---            <nak>
  1347. <soh> 01 FE -data- <xx>    --->
  1348.             <---            <ack>
  1349. <soh> 02 FD -data- <xx>    --->        (data gets line hit)
  1350.             <---            <nak>
  1351. <soh> 02 FD -data- <xx>    --->
  1352.             <---            <ack>
  1353. <soh> 03 FC -data- <xx>    --->
  1354.    (ack    gets garbaged)    <---            <ack>
  1355.                 times out after    10 seconds,
  1356.             <---            <nak>
  1357. <soh> 03 FC -data- <xx>    --->
  1358.             <---            <ack>
  1359. <eot>            --->
  1360.             <---            <ack>
  1361.  
  1362. Here is    a data flow example for    the case where the receiver requests
  1363. transmission in    the CRC    mode and the sender supports the CRC option.  This
  1364. example    also includes various transmission errors.  <xxxx> represents the
  1365. 2 CRC bytes.
  1366.  
  1367.  
  1368.  
  1369.  
  1370.  
  1371.  
  1372.  
  1373.  
  1374.  
  1375.  
  1376.  
  1377.  
  1378.  
  1379.  
  1380.  
  1381.  
  1382. Chapter    7                      Xmodem Protocol Overview
  1383.  
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390. X/YMODEM Protocol Reference     10-10-85                22
  1391.  
  1392.  
  1393.  
  1394.        Figure 12.  Receiver    and Sender Both    have CRC Option
  1395.  
  1396. SENDER                         RECEIVER
  1397.               <---               <C>
  1398. <soh> 01 FE -data- <xxxx> --->
  1399.               <---               <ack>
  1400. <soh> 02 FD -data- <xxxx> --->           (data gets line hit)
  1401.               <---               <nak>
  1402. <soh> 02 FD -data- <xxxx> --->
  1403.               <---               <ack>
  1404. <soh> 03 FC -data- <xxxx> --->
  1405. (ack gets garbaged)      <---               <ack>
  1406.                      times out after 10    seconds,
  1407.               <---               <nak>
  1408. <soh> 03 FC -data- <xxxx> --->
  1409.               <---               <ack>
  1410. <eot>              --->
  1411.               <---               <ack>
  1412.  
  1413.  
  1414. 8.  MORE INFORMATION
  1415.  
  1416. More information may be    obtained by calling Telegodzilla at 503-621-3746.
  1417. Hit RETURNs for    baud rate detection.
  1418.  
  1419. A version this file with boldface, underlining,    and superscripts for
  1420. printing on Epson or Gemini printers is    available on Telegodzilla as
  1421. "YMODEME.DOC" or "YMODEME.DQC".
  1422.  
  1423. UUCP sites can obtain this file    with
  1424.          uucp omen!/usr/spool/uucppublic/ymodem.doc    /tmp
  1425.  
  1426. The following L.sys line calls Telegodzilla (Pro-YAM in    host operation).
  1427. Telegodzilla waits for carriage    returns    to determine the incoming speed.
  1428. If none    is detected, 1200 bps is assumed and a greeting    is displayed.
  1429.  
  1430. In response to "Name Please:" uucico gives the Pro-YAM "link" command as a
  1431. user name.  The    password (Giznoid) controls access to the Xenix    system
  1432. connected to the IBM PC's other    serial port.  Communications between
  1433. Pro-YAM    and Xenix use 9600 bps;    YAM converts this to the caller's speed.
  1434.  
  1435. Finally, the calling uucico logs in as uucp.
  1436.  
  1437. omen Any ACU 1200 1-503-621-3746 se:--se: link ord: Giznoid in:--in: uucp
  1438.  
  1439. Contact    omen!caf if you    wish the troff sources.
  1440.  
  1441.  
  1442.  
  1443.  
  1444.  
  1445.  
  1446.  
  1447.  
  1448. Chapter    9                      Xmodem Protocol Overview
  1449.  
  1450.  
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456. X/YMODEM Protocol Reference     10-10-85                23
  1457.  
  1458.  
  1459.  
  1460. 9.  YMODEM Programs
  1461.  
  1462. A demonstration    version    of Professional-YAM is available as YAMDEMO.LQR    (A
  1463. SQueezed Novosielski library).    This may be used to test YMODEM
  1464. implementations.
  1465.  
  1466. Unix programs supporting the YMODEM protocol are available on Telegodzilla
  1467. in the "upgrade" subdirectory as RBSB.SHQ (a SQueezed shell archive).
  1468. Most Unix like systems are supported, including    V7, Sys    III, 4.2 BSD, SYS
  1469. V, Idris, Coherent, and    Regulus.
  1470.  
  1471. A version for VAX-VMS is available in VRBSB.SHQ, in the    same directory.
  1472.  
  1473. A CP/M assembly    version    is available as    MODEM76.AQM and    MODEM7.LIB.
  1474.  
  1475. Irv Hoff has added YMODEM 1k packets and YMODEM    batch transfers    to the KMD
  1476. and IMP    series programs, which replace the XMODEM and MODEM7/MDM7xx series
  1477. respectively.  Overlays    are available for a wide variety of CP/M systems.
  1478.  
  1479. MEX and    MEX-PC also support some of the    YMODEM extensions.
  1480.  
  1481. Questions about    YMODEM,    the Professional-YAM communications program, and
  1482. requests for evaluation    copies may be directed to:
  1483.      Chuck Forsberg
  1484.      Omen Technology Inc
  1485.      17505-V Sauvie Island Road
  1486.      Portland Oregon 97231
  1487.      Voice: 503-621-3406
  1488.      Modem: 503-621-3746 Speed:    1200,300
  1489.      Usenet: ...!tektronix!reed!omen!caf
  1490.      Compuserve: 70715,131
  1491.      Source: TCE022
  1492.  
  1493.  
  1494.  
  1495.  
  1496.  
  1497.  
  1498.  
  1499.  
  1500.  
  1501.  
  1502.  
  1503.  
  1504.  
  1505.  
  1506.  
  1507.  
  1508.  
  1509.  
  1510.  
  1511.  
  1512.  
  1513.  
  1514. Chapter    9                      Xmodem Protocol Overview
  1515.  
  1516.  
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522.  
  1523.  
  1524.  
  1525.  
  1526.                  CONTENTS
  1527.  
  1528.  
  1529. 1.  ROSETTA STONE.....................................................     2
  1530.  
  1531. 2.  YET    ANOTHER    PROTOCOL?.............................................     2
  1532.     2.1     Some Messages from the    Pioneer...............................     4
  1533.  
  1534. 3.  XMODEM PROTOCOL ENHANCEMENTS......................................     5
  1535.     3.1     Graceful Abort...............................................     6
  1536.     3.2     CRC-16    Option................................................     6
  1537.     3.3     1024 Byte Packet Option......................................     7
  1538.  
  1539. 4.  YMODEM Batch File Transmission....................................     8
  1540.     4.1     IMP/KMD Record    Count.........................................    13
  1541.  
  1542. 5.  g Option File Transmission........................................    13
  1543.  
  1544. 6.  XMODEM PROTOCOL OVERVIEW..........................................    14
  1545.     6.1     Definitions..................................................    14
  1546.     6.2     Transmission Medium Level Protocol...........................    14
  1547.     6.3     File Level Protocol..........................................    15
  1548.     6.4     Programming Tips.............................................    17
  1549.  
  1550. 7.  XMODEM/CRC Overview...............................................    18
  1551.     7.1     CRC Calculation..............................................    18
  1552.     7.2     CRC File Level    Protocol Changes..............................    19
  1553.     7.3     Data Flow Examples with CRC Option...........................    21
  1554.  
  1555. 8.  MORE INFORMATION..................................................    22
  1556.  
  1557. 9.  YMODEM Programs...................................................    23
  1558.  
  1559.  
  1560.  
  1561.  
  1562.  
  1563.  
  1564.  
  1565.  
  1566.  
  1567.  
  1568.  
  1569.  
  1570.  
  1571.  
  1572.  
  1573.  
  1574.  
  1575.  
  1576.  
  1577.  
  1578.  
  1579.  
  1580.                   - i -
  1581.  
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588.  
  1589.  
  1590.  
  1591.  
  1592.  
  1593.  
  1594.  
  1595.                  LIST OF FIGURES
  1596.  
  1597.  
  1598.  Figure    1.  1024 byte Packets.........................................     7
  1599.  
  1600.  Figure    2.  Mixed 1024 and 128 byte Packets...........................     7
  1601.  
  1602.  Figure    3.  Batch Transmission Session................................    11
  1603.  
  1604.  Figure    4.  Filename packet transmitted    by sb.........................    11
  1605.  
  1606.  Figure    5.  Header Information used by YMODEM Implementations.........    13
  1607.  
  1608.  Figure    6.  g Option Transmission Session.............................    14
  1609.  
  1610.  Figure    7.  XMODEM Message Block Level Protocol.......................    15
  1611.  
  1612.  Figure    8.  Data flow including    Error Recovery........................    17
  1613.  
  1614.  Figure    9.  Message Block Level    Protocol, CRC mode....................    18
  1615.  
  1616. Figure 10.  Example of CRC Calculation written in C...................    19
  1617.  
  1618. Figure 11.  Data Flow: Receiver    has CRC    Option,    Sender Doesn't........    21
  1619.  
  1620. Figure 12.  Receiver and Sender    Both have CRC Option..................    22
  1621.  
  1622.  
  1623.  
  1624.  
  1625.  
  1626.  
  1627.  
  1628.  
  1629.  
  1630.  
  1631.  
  1632.  
  1633.  
  1634.  
  1635.  
  1636.  
  1637.  
  1638.  
  1639.  
  1640.  
  1641.  
  1642.  
  1643.  
  1644.  
  1645.  
  1646.                   - ii -
  1647.  
  1648.  
  1649.  
  1650.